package com.zq.recruit.controller;

import com.github.pagehelper.PageInfo;
import com.zq.common.util.Result;
import com.zq.recruit.dao.dto.CompanyDto;
import com.zq.recruit.dao.entity.Company;
import com.zq.recruit.service.CompanyService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author 张乔
 * @Date 2025/3/16 16:41
 */
@RestController
@RequestMapping("/recruit/company")
public class CompanyController {

    @Resource
    private CompanyService companyService;

    //分页条件查询
    @GetMapping("/findByPage/{pageNum}/{pageSize}")
    public Result<Object> findByPage(CompanyDto sysUserDto ,
                                     @PathVariable(value = "pageNum") Integer pageNum ,
                                     @PathVariable(value = "pageSize") Integer pageSize) {
        PageInfo<Company> pageInfo =companyService.findByPage(sysUserDto,pageNum,pageSize);
        return     Result.successData(pageInfo);

    }



    @GetMapping("/getAll")
    public Result<Object> getAll(){
        List<Company> list = companyService.list();
        return Result.successData(list);
    }





@PostMapping("/addCompany")
    public Result<String> addCompany(@RequestBody Company company){
    companyService.save(company);
    return Result.success();
}

@PutMapping("/updateCompany")
    public Result<String> updateCompany(@RequestBody Company company){
    companyService.updateById(company);
    return Result.success();
}

@DeleteMapping("/deleteCompany/{id}")
    public Result<String> deleteCompany(@PathVariable("id") Integer id){
    companyService.removeById(id);
    return Result.success();
}



}
